const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');
const apiMocker = require('mocker-api') //使用mocker-api库
const path = require('path')

module.exports = {
	outputDir: 'dist',
	publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
	productionSourceMap: false,
	css: {
		loaderOptions: {
			postcss: {
				plugins: [
					autoprefixer(),
					pxtorem({
						rootValue: 37.5,
						propList: ['*']
					})
				]
			}
		}
	},
	devServer: {
		//如果使用mocker-api库
		before(app) {
			apiMocker(app, path.resolve('./mock/index.js'), {

			})
		},
		port: 8080,
		disableHostCheck: true,
		proxy: {
			'/api': {
				target: 'https://huiyan.baidu.com', //服务地址
				ws: false,
				changeOrigin: true,
				pathRewrite: { '^/api': '' }
			},
		}
	},
};
